import com.FQJ.stock.BackendApp;
import com.FQJ.stock.mapper.StockRtInfoMapper;
import com.FQJ.stock.mapper.SysUserMapper;
import com.FQJ.stock.pojo.domain.StockUpdownDomain;
import com.FQJ.stock.pojo.entity.SysUser;
import com.FQJ.stock.service.StockService;
import com.FQJ.stock.utils.DateTimeUtil;
import com.github.benmanes.caffeine.cache.Cache;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;

//失败的，不知道为什么，我有点着急呀
@SpringBootTest(classes = BackendApp.class)
public class test01 {

	@Autowired
	private SysUserMapper sysUserMapper;

	private SysUser sysUser;
	@Test
	public void test(){
		sysUser=sysUserMapper.getUserByUserName("admin");
		System.out.println(sysUser);
	}
	@Autowired
	private StockRtInfoMapper stockRtInfoMapper;
	@Autowired
	private Cache<String,Object> caffeineCache;
	@Autowired
	private StockService stockService;
	@Test
	public void test02(){
		//获取股票最新交易时间点
		Date lastDate= DateTimeUtil.getLastDate4Stock(DateTime.now()).toDate();
		//TODO mock数据,后续删除
		lastDate=DateTime.parse("2021-12-30 09:42:00", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate();
		Date curDate = DateTimeUtil.getLastDate4Stock(DateTime.now()).toDate();
		//todo
		curDate= DateTime.parse("2022-06-07 15:00:00", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toDate();

		List<StockUpdownDomain> list=stockRtInfoMapper.findAll(lastDate);
		System.out.println(list);
	}

	@Test
	public void test03(){
		//stockService.innerIndexAll();
		Object innerMarketKey = caffeineCache.getIfPresent("innerMarketKey");
		System.out.println(innerMarketKey);
	}


}
